import Vue from 'vue'
import Vuex, { storeKey } from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    username:'',   //sessionStorage.getItem('name')   //用于保存当前用户名
  },
  getters: {
  },
  mutations: {
//state就是vuex.state   newName是传递过来的新用户名参数
    updateName(state,newName){
      state.username=newName
      // 将username存入sessionStorage   刷新不变,关闭浏览器变化
      window.sessionStorage.setItem('name',newName)
    }
  },
  actions: {
  },
  modules: {
  }
})
